<template>
    <el-dialog
      :visible.sync="visible"
      :title="dataForm.details ? '详情' :(!dataForm.id ? $t('add') : $t('update'))"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      @close="close()"
      :destroy-on-close="true"
    >
      <el-form
        :model="dataForm"
        :rules="dataRule"
        ref="dataForm"
        @keyup.enter.native="dataFormSubmitHandle()"
        :label-width="$i18n.locale === 'en-US' ? '120px' : '120px'"
        label-position="right"
        :disabled="disabled"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="车牌号">
                <b>{{ dataForm.numberplate }}</b>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车牌类型">
                <b>{{ dataForm.numberplateColourText }}</b>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="停车地点">
                <b>{{ dataForm.parkadeName }}</b>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人员姓名">
                <b>{{ dataForm.name }}</b>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="进场时间">
                <b>{{ dataForm.enterTime }}</b>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="离场时间">
                <b>{{ dataForm.leaveTime }}</b>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="停车时长">
                <b>{{ dataForm.parkingDuration }}</b>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="停车花费">
                <b>{{ dataForm.paymentAmount }}元</b>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template slot="footer" v-if="!disabled">
        <el-button @click="visible = false">{{ $t("cancel") }}</el-button>
        <el-button type="primary" @click="dataFormSubmitHandle()">{{
          $t("confirm")
        }}</el-button>
      </template>
    </el-dialog>
  </template>
  
  <script>
  import mixinRegionModule from "@/mixins/region-module";
  
  export default {
    mixins: [mixinRegionModule],
  
    data() {
      return {
        visible: false,
        dataForm:{}
      };
    },
    props: { disabled: Boolean },
    computed: {
      dataRule() {
        return { };
      },
    },
    methods: {
      close() {
        this.$emit("changeDisabled");
      },
  
      init() {
        this.visible = true;
        this.$nextTick(() => {
          this.$refs["dataForm"].resetFields();
          if (this.dataForm.id) {
            this.getInfo();
          }
        });
      },
      // 获取信息
      getInfo() {
        this.$http
          .get("/travel/car/wharfStopRecord/" + this.dataForm.id)
          .then(({ data: res }) => {
            if (res.code !== 0) {
              return this.$message.error(res.msg);
            }
            this.dataForm = {
              ...this.dataForm,
              ...res.data,
            };
            this.dataForm.numberplateColourText = this.$parent.$parent.licences[this.dataForm.numberplateColour]||'';
          })
          .catch(() => {});
      }
    }
  };
  </script>
  